﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AmiEmuLib.AmigaMachine.AmigaMemory
{
    public class MirrorMemoryBank : MemoryBank
    {
        public readonly MemoryBank Source;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="a_address"></param>
        /// <param name="a_memory"></param>
        /// <param name="a_type,"></param>
        /// <param name="a_fast"></param>
        public MirrorMemoryBank(uint a_address, MemoryBank a_source)
            : base(a_address, a_source.Memory, a_source.Type, a_source.Fast)
        {
            Source = a_source;
        }

        internal override void Reset()
        {
            Source.Reset();
        }

        public override byte GetByte(uint a_address)
        {
            return Source.GetByte(Source.Address - Address + a_address);
        }

        public override void SetByte(uint a_address, byte a_value)
        {
            Source.SetByte(Source.Address - Address + a_address, a_value);
        }

        public override ushort GetWord(uint a_address)
        {
            return Source.GetWord(Source.Address - Address + a_address);
        }

        public override void SetWord(uint a_address, ushort a_value)
        {
            Source.SetWord(Source.Address - Address + a_address, a_value);
        }

        public override uint GetLong(uint a_address)
        {
            return Source.GetLong(Source.Address - Address + a_address);
        }

        public override void SetLong(uint a_address, uint a_value)
        {
            Source.SetLong(Source.Address - Address + a_address, a_value);
        }
    }
}
